<template>
	<view class="container">
		<view class="use-box">
			<view class="use-item" :class="{'fin' : item.isEnd}" v-for="(item,index) in dataList" :key="index">
				<view class="sx center" :class="{'fin' : item.isEnd}">{{item.isEnd ? '已完成':'生效中'}}</view>
				<view>
					<view class="tit" :class="{'active' : !item.isEnd}">富侨汇会员年卡</view>
					<view class="text">{{item.payTime}} 支付成功</view>
					<view class="time">年卡有效期：{{item.vipStartTime}}-{{item.vipEndTime}}</view>
				</view>
				<view class="right">实付￥{{item.payPrice}}</view>
			</view>
			<view class="no-data" v-if="!dataList.length">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		buyList
	} from "../../api/active"
	import {
		getTime
	} from "../../utils/plug.js"
	export default {
		data() {
			return {
				dataList: []
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData() {
				uni.showLoading({
					title: "加载中..."
				})
				buyList({
						userId: uni.getStorageSync("userId"),
						status: 2,
						size: 500,
						current: 1
					})
					.then(res => {
						this.show = true
						uni.hideLoading()
						this.dataList = res.data.records
						this.dataList.length && this.dataList.forEach(item=>{
							item.isEnd = new Date().getTime() > item.vipEndTime ? true : false
							item.vipStartTime = getTime(item.vipStartTime)
							item.vipEndTime = getTime(item.vipEndTime)
							item.payTime = getTime(item.payTime)
						})
						console.log(this.dataList)
					})
					.catch(() => {
						uni.hideLoading()
					})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.no-data {
		font-weight: 500;
		font-size: 26rpx;
		color: #999999;
		text-align: center;
		padding-top: 20rpx;
	}

	.container {
		width: 100vw;
		min-height: 100vh;
		background: #f5f5f5;
		padding: 0 25rpx 20rpx 25rpx;
	}

	.use-box {
		display: flex;
		flex-direction: column;
	}

	.use-item {
		width: 100%;
		margin-top: 20rpx;
		height: 206rpx;
		background: linear-gradient(90deg, #2A1609, #59331B);
		border-radius: 20rpx;
		position: relative;
		padding: 0rpx 20rpx 0 40rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		&.fin {
			background: #DDDDDD;
			.tit {
				color: #666666;
				-webkit-background-clip: none;
				-webkit-text-fill-color: none;
			}
			.text {
				color: #999999;
			}
			.time {
				color: #999999;
			}
			.right {
				color: #999999;
			}
		}
		.tit {
			font-weight: 800;
			font-size: 34rpx;
			color: #333333;
			&.active {
				background: linear-gradient(-90deg, #FFE1B1 0%, #D9A472 100%);
				-webkit-background-clip: text;
				-webkit-text-fill-color: transparent;
			}
		}
		.text {
			font-weight: 500;
			font-size: 24rpx;
			color: #AF9B7E;
			margin-top: 15rpx;
		}
		.time {
			font-weight: 500;
			font-size: 26rpx;
			color: #CBAF88;
			margin-top: 30rpx;
		}
		.right {
			font-weight: 500;
			font-size: 24rpx;
			color: #CBAF88;
		}
		.sx {
			width: 100rpx;
			height: 40rpx;
			background: #FCCA00;
			border-radius: 0rpx 20rpx 0rpx 20rpx;
			font-weight: 500;
			font-size: 22rpx;
			color: #2B1709;
			position: absolute;
			top: 0;
			right: 0;
			&.fin {
				background: #C0C0C0;
				color: #666666;
			}
		}
	}
</style>